<style>
    .qudao dl{clear: both}
    .kdzm li{padding-right: 0 !important;padding: 0 1px 0 0;}
</style>
<div class="admin_nrtop">
    <div class="yundantopleft">
        <div class="yundancz">
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a href="/admini/returngoods/index" class="nui-btn-text"><span>&lt;&lt;</span>返回</a>
                </div>
            </div>

            <div class="nui-toolbar-item">
                <div class="nui-btn" id="interiorAll">
                    <a href="javascript:void()" class="nui-btn-text rxl" id="interiorChange">修改状态<i></i></a>
                    <div class="ztlist" style="display:none;" id="interiorBox">
                        <ul>
                            <?php foreach (Application_Model_ReturnGoods::getStatusAll() as $key => $val) { ?>
                                <li><a href="javascript:editInterior(<?php echo $key; ?>);" name="<?= $this->detail->id ?>" id="editInterior<?= $key ?>"><?= $val ?></a></li>
                            <?php } ?>
                        </ul>
                    </div>
                </div>
                <div class="nui-btn ">
                    <a href="javascript:remark();" class="nui-btn-text">备注</a>
                </div>
                <div class="nui-btn ">
                    <a href="javascript:unusual();" class="nui-btn-text">异常</a>
                </div>
                <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Refund && $this->detail->type == Application_Model_ReturnGoods::TYPE_Return && $this->detail->source == Application_Model_ReturnGoods::SOURCE_Agency) { ?>
                    <div class="nui-btn ">
                        <a href="javascript:rechargebox();" class="nui-btn-text">会员退款</a>
                    </div>
                <?php } ?>
                <div class="nui-btn ">
                    <a href="javascript:deletebyid(<?php echo $this->detail->id; ?>)" class="nui-btn-text">取消删除</a>
                </div>               
            </div>     
        </div>
        <div class="yundangrinfo">
            <p>用户：<a href="/admini/manageuser/userdetail/id/<?= $this->detail->userId ?>"><?= $this->detail->UserInfo->nikename ?></a><span>|</span>仓库号：<a href="/admini/managestore/index/history/2/quick/<?= $this->detail->UserInfo->storeno ?>"><?= $this->detail->userinfo->storeno ?></a><span>|</span>提交时间：<?= $this->detail->datetime ? $this->detail->datetime : "暂无" ?><span>|</span>付款时间：<?= $this->detail->paytime ? $this->detail->paytime : "暂无" ?></p>
        </div>
    </div>
    <div class="yundantopright">
        <p>用户ID：<?= $this->detail->userId ?></p>
    </div>
    <div class="buzhou" style="clear:both">
        <?php if ($this->detail->type == Application_Model_ReturnGoods::TYPE_Return) { ?>
            <div class="bzbox" style="display:block;">
                <?php if ($this->detail->type == Application_Model_ReturnGoods::TYPE_Return && $this->detail->source == Application_Model_ReturnGoods::SOURCE_Agency) { ?>
                    <table>
                        <tr>
                            <?php
                            $interiorall = $this->detail->StatusCorrect;
                            foreach ($interiorall as $key => $interiorval) {
                                $log = Application_Model_WayLog::getByWayIdInteriorType($this->detail->id, $key, Application_Model_WayLog::Type_Return);
                                ?>
                                <td <?php echo $log ? 'class="bz_wanl"' : ""; ?>>
                                    <div class="bzloading">
                                        <div class="dian"><?php echo ($log ? '<a href="javascript:void(0)"><i></i><span>' . $interiorval[1] : '<i></i><span>' . $interiorval[0]) . '</span></a>'; ?></div>
                                        <?php if ($log) { ?>
                                            <div class="bzxiangbox" style="display: none;">
                                                <div class="xjiantou"></div>
                                                <div class="xianginfo">
                                                    <ul>
                                                        <li><label>处理时间：</label><em><?php echo $log->dateCreated; ?></em></li>
                                                        <li><label>责任人：</label><em><?php echo $log->operator; ?></em></li>
                                                    </ul>
                                                </div>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </td>
                            <?php } ?>
                            <!--流程全完class="bz_wanr"-->
                            <td <?php
                            if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Succeed) {
                                echo "class=bz_wanr";
                            }
                            ?>></td>
                        </tr>
                    </table>
                <?php } else if ($this->detail->type == Application_Model_ReturnGoods::TYPE_Return && $this->detail->source != Application_Model_ReturnGoods::SOURCE_Agency) { ?>
                    <table>
                        <tr>
                            <?php
                            $interiorall = $this->detail->StatusCorrect2;
                            foreach ($interiorall as $key => $interiorval) {
                                $log = Application_Model_WayLog::getByWayIdInteriorType($this->detail->id, $key, Application_Model_WayLog::Type_Return);
                                ?>
                                <td <?php echo $log ? 'class="bz_wanl"' : ""; ?>>
                                    <div class="bzloading">
                                        <div class="dian"><?php echo ($log ? '<a href="javascript:void(0)"><i></i><span>' . $interiorval[1] : '<i></i><span>' . $interiorval[0]) . '</span></a>'; ?></div>
                                        <?php if ($log) { ?>
                                            <div class="bzxiangbox" style="display: none;">
                                                <div class="xjiantou"></div>
                                                <div class="xianginfo">
                                                    <ul>
                                                        <li><label>处理时间：</label><em><?php echo $log->dateCreated; ?></em></li>
                                                        <li><label>责任人：</label><em><?php echo $log->operator; ?></em></li>
                                                    </ul>
                                                </div>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </td>
                            <?php } ?>
                            <!--流程全完class="bz_wanr"-->
                            <td <?php
                            if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Succeed) {
                                echo "class=bz_wanr";
                            }
                            ?>></td>
                        </tr>
                    </table>                
                <?php } ?>
            </div>
        <?php } else { ?>
            <div class="bzbox" style="display:block;">
                <table>
                    <tr>
                        <?php
                        $interiorall = $this->detail->StatusCorrect3;
                        foreach ($interiorall as $key => $interiorval) {
                            $log = Application_Model_WayLog::getByWayIdInteriorType($this->detail->id, $key, Application_Model_WayLog::Type_Return);
                            ?>
                            <td <?php echo $log ? 'class="bz_wanl"' : ""; ?>>
                                <div class="bzloading">
                                    <div class="dian"><?php echo ($log ? '<a href="javascript:void(0)"><i></i><span>' . $interiorval[1] : '<i></i><span>' . $interiorval[0]) . '</span></a>'; ?></div>
                                    <?php if ($log) { ?>
                                        <div class="bzxiangbox" style="display: none;">
                                            <div class="xjiantou"></div>
                                            <div class="xianginfo">
                                                <ul>
                                                    <li><label>处理时间：</label><em><?php echo $log->dateCreated; ?></em></li>
                                                    <li><label>责任人：</label><em><?php echo $log->operator; ?></em></li>
                                                </ul>
                                            </div>
                                        </div>
                                    <?php } ?>
                                </div>
                            </td>
                        <?php } ?>
                        <!--流程全完class="bz_wanr"-->
                        <td <?php
                        if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Succeed) {
                            echo "class=bz_wanr";
                        }
                        ?>></td>
                    </tr>
                </table>
            </div>
        <?php } ?>

    </div>
</div>    
<div class="yundan_top">
    <table class="yunxinxi">
        <tr>
            <td class="ydleft">
                <div class="zhuangtai">
                    <i></i><h1><?php echo $this->detail->IsDelete == 1 ? "已取消" : $this->detail->StatusName; ?></h1><span>[<?= $this->detail->TypeName ?>]</span>
                    <?php if ($this->detail->Problem == Application_Model_ReturnGoods::Problem_Exception || $this->detail->Problem == Application_Model_ReturnGoods::Problem_Loss) { ?><h1 style="color:#c00;"><?php echo $this->detail->ProblemName; ?></h1><?php } ?>
                </div>
                <div class="shouli">
                    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Payment) { ?>
                        <a class="anvbotton5" href="javascript:accepted(<?php echo $this->detail->id; ?>);"><span>受理</span></a>
                    <?php } ?>
                </div>
            </td>
            <td class="ydtopline">
                <div class="zhtailan">
                    <label>包裹图片：</label>
                </div>
            </td>
        </tr>
        <tr>
            <td class="ydleft">
                <table>
                    <tr>
                        <td class="xleft">物流公司(发)：</td>
                        <td class="xlright"><?= $this->detail->logisticsName ? $this->detail->logisticsName : "暂无" ?></td>
                        <td class="xleft">物流单号(发):</td>
                        <td class="xlright"><?= $this->detail->logistics ? $this->detail->logistics : "暂无" ?></td>
                    </tr>
                    <?php if ($this->detail->type == Application_Model_ReturnGoods::TYPE_Change) { ?>
                        <tr>
                            <td class="xleft">物流公司(收):</td>
                            <td class="xlright"><?= $this->detail->reLogisticsName ? $this->detail->reLogisticsName : "暂无" ?></td>
                            <td class="xleft">物流单号(收):</td>
                            <td class="xlright"><?= $this->detail->reLogistics ? $this->detail->reLogistics : "暂无" ?></td>
                        </tr>
                    <?php } ?>
                    <tr>
                        <td class="xleft">运费(发):</td>
                        <td class="xlright">￥ <?= $this->detail->freight ? $this->detail->freight . "(" . $this->detail->ReturnTypeName . ")" : 0 ?></td>
                    </tr>
                    <?php if ($this->detail->type == Application_Model_ReturnGoods::TYPE_Change) { ?>
                        <tr>
                            <td class="xleft">换货时间：</td>
                            <td class="xlright"><?= $this->detail->reDatetime ? $this->detail->reDatetime : "暂无" ?></td>
                            <td class="xleft">运费(收):</td>
                            <td class="xlright">￥ <?= $this->detail->reFreight ? $this->detail->reFreight : 0 ?></td>
                        </tr>
                    <?php } ?>
                    <tr>
                        <td class="xleft">退换货原因：</td>
                        <td class="xlright" colspan="3"><?= $this->detail->returnReason ? $this->detail->returnReason : "暂无" ?></td>
                    </tr>
                    <tr>
                        <td class="xleft">退货地址：</td>
                        <td class="xlright" colspan="3"><?= $this->detail->returnAddress ? $this->detail->returnAddress : "暂无" ?></td>
                    </tr>
                    <?php if ($this->detail->Problem == Application_Model_ReturnGoods::Problem_Exception || $this->detail->Problem == Application_Model_ReturnGoods::Problem_Loss) { ?>
                        <tr>
                            <td class="xleft">异常信息：</td>
                            <td class="xlright" colspan="3"><font style="color:red;"><?= $this->detail->Exception ?></font></td>
                        </tr>
                    <?php } ?>
                    <?php foreach ($this->detail->StoreInfo as $key => $storeVal) { ?>
                        <tr>
                            <td class="xleft" style="width:130px;">物品编号：</td>
                            <td class="xlright"><?= $storeVal->barcode ?></td>
                            <td class="xleft" style="width:130px;">来源：</td>
                            <td class="xlright"><?= $storeVal->intype ?></td>
                        </tr>
                        <tr>
                            <td class="xleft">包裹名称：</td>
                            <td class="xlright" colspan="3"><?= $storeVal->productName ?></td>
                        </tr>
                    <?php } ?>
                </table>
            </td>
            <td class="ydtopline sdq" rowspan="2">    
                <?php foreach ($this->detail->StoreInfo as $key => $stVal) { ?>
                    <div style="float: left;">
                        <span>物品<?php echo $key + 1; ?>图片</span><br>
                        <a href="<?= $this->cdn ?><?= !is_int(strpos('big', $stVal->imageFile)) ? ('/big' . $stVal->imageFile) : ($stVal->imageFile) ?>"  target="_blank">
                            <img src="<?= $this->cdn ?><?= !is_int(strpos('big', $stVal->imageFile)) ? ('/big' . $stVal->imageFile) : ($stVal->imageFile) ?>" style="vertical-align:middle;width: 330px;height: 330px;"/>
                        </a>
                        <br>
                    </div>
                <?php } ?>  
            </td>
        </tr>
        <tr>
            <td class="ydleft">
                <table>
                    <tr>
                        <td class="xleft">备注：</td>
                        <td><?= $this->detail->returnNote ? $this->detail->returnNote : "无" ?></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
<?php if ($this->detail->IsDelete != 1 && ($this->detail->Problem == Application_Model_ReturnGoods::Problem_Defalut || $this->detail->Problem == Application_Model_ReturnGoods::Problem_Process)) { ?>
    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Accepted) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>处理中</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:deal(<?php echo $this->detail->id; ?>)" class="anvbotton5" style="float:left;"><span>打包包裹</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Process) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>发包</p>
                    </td>
                    <td>

                        <div class="qudao">
                            <dl>
                                <dt>快递公司(发)：</dt>
                                <dd>
                                    <div class="biaoxiala">
                                        <div class="textbox"><input class="textinput w250" type="hidden" name="logisticsName" id="logisticsName"/></div>
                                        <div class="lixiala courierCompany">
                                            <span>请选择...</span>
                                            <i id="courier"></i>
                                        </div>
                                        <div class="kdtc" style="display:none;">
                                            <div class="kdremen">
                                                <h4>热门快递公司</h4>
                                                <ul>
                                                    <li><a href="javascript:void()" name="EMS" class="kditem">EMS</a></li>
                                                    <li><a href="javascript:void()" name="顺丰" class="kditem">顺丰</a></li>
                                                    <li><a href="javascript:void()" name="申通" class="kditem">申通</a></li>
                                                    <li><a href="javascript:void()" name="中通" class="kditem">中通</a></li>
                                                    <li><a href="javascript:void()" name="圆通" class="kditem">圆通</a></li>
                                                    <li><a href="javascript:void()" name="宅急送" class="kditem">宅急送</a></li>
                                                    <li><a href="javascript:void()" name="韵达" class="kditem">韵达</a></li>
                                                </ul>
                                            </div>
                                            <div class="allkd">
                                                <h4>全部快递</h4>
                                                <ul class="kdzm">
                                                    <?php foreach ($this->words as $char) { ?>
                                                        <li <?php echo $char == 'A' ? 'class="kon"' : ''; ?>><a href="javascript:void()"><?php echo $char; ?></a></li>
                                                    <?php } ?>
                                                </ul>
                                                <div id="courierTb">
                                                    <?php foreach ($this->words as $char) { ?>
                                                        <ul class="kdlist" <?php echo $char == 'A' ? '' : 'style="display:none"'; ?>>
                                                            <?php $courierList = Application_Model_shipType::getByWord($char); ?>
                                                            <?php foreach ($courierList as $courier) { ?>
                                                                <li><a href="javascript:void()" name="<?php echo $courier->name; ?>"  class="kditem"><?php echo $courier->name; ?></a></li>
                                                            <?php } ?>
                                                        </ul>
                                                    <?php } ?>                          
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </dd>
                            </dl>
                            <dl>
                                <dt>快递单号(发)：</dt>
                                <dd>
                                    <div class="textbox"><input class="textinput w250" type="text" name="logistics" id="logistics"/></div>
                                </dd>
                            </dl> 
                            <dl>
                                <dt>运费(发)：</dt>
                                <dd>
                                    <div class="textbox"><input class="textinput w80" type="text" name="freight" id="freight"/></div>
                                </dd>
                            </dl> 
                            <dl>
                                <dt>运费类型：</dt>
                                <dd>
                                    <div class="textbox"><select id="returnType" name="returnType" class="textinput" style="height: 32px;">
                                            <?php foreach ($this->returnTypeAll as $returnKey => $returnVal) { ?>
                                                <option value="<?php echo $returnKey; ?>"><?php echo $returnVal; ?></option>
                                            <?php } ?>
                                        </select></div>
                                </dd>
                            </dl> 
                            <div class="lctijiao">
                                <a href="javascript:void(0)" onclick="javascript:send(<?php echo $this->detail->id; ?>, $(this))" class="anvbotton5" style="float:left;"><span>已发包</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Send) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>通知客户</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:notice(<?php echo $this->detail->id; ?>)" class="anvbotton5" style="float:left;"><span>已通知</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Informed) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>等待对方收件</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:waitingreceipt(<?php echo $this->detail->id; ?>)" class="anvbotton5" style="float:left;"><span>对方已收件</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Received && $this->detail->source == Application_Model_ReturnGoods::SOURCE_Agency && $this->detail->type == Application_Model_ReturnGoods::TYPE_Return) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>待卖家退款</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:refund(<?php echo $this->detail->id; ?>);" class="anvbotton5" style="float:left;"><span>卖家已退款</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } else if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Refund && $this->detail->type == Application_Model_ReturnGoods::TYPE_Return && $this->detail->source == Application_Model_ReturnGoods::SOURCE_Agency) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>退款</p></td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:rechargebox();" class="anvbotton5" style="float:left;"><span>点击退款</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } else if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Received && $this->detail->source != Application_Model_ReturnGoods::SOURCE_Agency && $this->detail->type == Application_Model_ReturnGoods::TYPE_Return) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>完成</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:succeed(<?php echo $this->detail->id; ?>);" class="anvbotton5" style="float:left;"><span>设为已完成</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>


    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Refee) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>完成</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:succeed(<?php echo $this->detail->id; ?>);" class="anvbotton5" style="float:left;"><span>已完成</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Received && $this->detail->type == Application_Model_ReturnGoods::TYPE_Change) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>对方待发件</p>
                    </td>
                    <td>
                        <div class="qudao">
                            <dl>
                                <dt>快递公司(收)：</dt>
                                <dd>

                                    <div class="biaoxiala">
                                        <div class="textbox"><input class="textinput w250" type="hidden" name="reLogisticsName" id="reLogisticsName"/></div>
                                        <div class="lixiala courierCompany">
                                            <span>请选择...</span>
                                            <i id="courier"></i>
                                        </div>
                                        <div class="kdtc" style="display:none;">
                                            <div class="kdremen">
                                                <h4>热门快递公司</h4>
                                                <ul>
                                                    <li><a href="javascript:void()" name="EMS" class="kditem">EMS</a></li>
                                                    <li><a href="javascript:void()" name="顺丰" class="kditem">顺丰</a></li>
                                                    <li><a href="javascript:void()" name="申通" class="kditem">申通</a></li>
                                                    <li><a href="javascript:void()" name="中通" class="kditem">中通</a></li>
                                                    <li><a href="javascript:void()" name="圆通" class="kditem">圆通</a></li>
                                                    <li><a href="javascript:void()" name="宅急送" class="kditem">宅急送</a></li>
                                                    <li><a href="javascript:void()" name="韵达" class="kditem">韵达</a></li>
                                                </ul>
                                            </div>
                                            <div class="allkd">
                                                <h4>全部快递</h4>
                                                <ul class="kdzm">
                                                    <?php foreach ($this->words as $char) { ?>
                                                        <li <?php echo $char == 'A' ? 'class="kon"' : ''; ?>><a href="javascript:void()"><?php echo $char; ?></a></li>
                                                    <?php } ?>
                                                </ul>
                                                <div id="courierTb">
                                                    <?php foreach ($this->words as $char) { ?>
                                                        <ul class="kdlist" <?php echo $char == 'A' ? '' : 'style="display:none"'; ?>>
                                                            <?php $courierList = Application_Model_shipType::getByWord($char); ?>
                                                            <?php foreach ($courierList as $courier) { ?>
                                                                <li><a href="javascript:void()" name="<?php echo $courier->name; ?>"  class="kditem"><?php echo $courier->name; ?></a></li>
                                                            <?php } ?>
                                                        </ul>
                                                    <?php } ?>                          
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </dd>
                            </dl>
                            <dl>
                                <dt>快递单号(收)：</dt>
                                <dd>
                                    <div class="textbox"><input class="textinput w250" type="text" name="reLogistics" id="reLogistics"/></div>
                                </dd>
                            </dl> 
                            <dl>
                                <dt>运费(收)：</dt>
                                <dd>
                                    <div class="textbox"><input class="textinput w80" type="text" name="reFreight" id="reFreight"/></div>
                                </dd>
                            </dl> 
                            <div class="lctijiao">
                                <a href="javascript:void(0)" onclick="javascript:resend(<?php echo $this->detail->id; ?>,$(this))" class="anvbotton5" style="float:left;"><span>对方已发件</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Resend) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>仓库待收件</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:receipt(<?php echo $this->detail->id; ?>);" class="anvbotton5" style="float:left;"><span>仓库已收件</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>

    <?php if ($this->detail->status == Application_Model_ReturnGoods::STATUS_Receipt) { ?>
        <div class="lcbox">
            <table class="lcks">
                <tr>
                    <td class="lcleft" style="width:150px;"><p>完成</p>
                    </td>
                    <td>
                        <div class="qudao">                    
                            <div class="lctijiao">
                                <a href="javascript:succeed(<?php echo $this->detail->id; ?>);" class="anvbotton5" style="float:left;"><span>已完成</span></a>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    <?php } ?>
<?php } ?>
<div class="tanchuang" style="display:none;" id="box_remark">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd" id="edithead">更新备注</div>
        <a class="nui-msgbox-close" title="关闭" id="exitissue"><b></b></a>
    </div>
    <div class="neirbox" style="text-align:center">
        <table style="width: 80%;margin:auto;margin-top: 38px;">
            <tr>
                <td class="askl">备注：</td>
                <td><textarea name="remark" id="remark" cols="60" rows="9"><?= $this->detail->returnNote ?></textarea></td>
            </tr>
        </table>
        <div class="neirboxok" style="width: 25%;margin:auto;margin-top: 16px;">
            <a class="anvbotton" href="javascript:editRemark(<?php echo $this->detail->id; ?>)"><span>确认提交</span></a>
        </div>  
    </div>
    <div class="unusualbox" style="text-align:center" style="display:none;">
        <table style="width: 88%;margin:auto;margin-top: 38px;">
            <tr>
                <td class="askl">异常信息：</td>
                <td><textarea name="exception" id="exception" cols="60" rows="9"><?= $this->detail->exception ?></textarea></td>
            </tr>
        </table>
        <div class="neirboxok" style="width: 150px;margin-top: 16px;display: inline;float:left;margin-left: 50px;">
            <a class="anvbotton" href="javascript:abnormal(<?php echo $this->detail->id; ?>)"><span>标记异常</span></a> 
        </div>  
        <div style="width: 150px;margin-top: 30px;display: inline;float:left;margin-left: 30px;">
            <a href="javascript:process(<?php echo $this->detail->id; ?>)" class="indexa"><span>异常解决</span></a> 
        </div> 
        <div class="neirboxok" style="width: 180px;margin-top: 16px;display: inline;float:right;">
            <a class="anvbotton" href="javascript:loss(<?php echo $this->detail->id; ?>)"><span>标记包裹丢失</span></a> 
        </div> 
    </div>
    <div class="rechargebox" style="text-align:center" style="display:none;">
        <table style="width: 80%;margin:auto;margin-top: 70px;">
            <?php foreach ($this->detail->StoreInfo as $key => $storeVal): ?>
                <?php if('代购订单' == $storeVal->intype): ?>
                <?php preg_match('/U[\d]+/', $storeVal->productName, $matches) ?>
                <tr height="36px;">
                    <td class="askl">代购订单:<?php echo isset($matches[0]) ? (string)$matches[0] : ''?>金额：<br />
                        (物品编号:<?php echo $storeVal->barcode ?>)
                    </td>
                    <td align="left">￥ <input type="text" name="<?php echo isset($matches[0]) ? (string)$matches[0] : ''?>" size="9px" class="orderReturngoodsMoney" /></td>
                </tr>
                <?php endif; ?>
            <?php endforeach; ?>
            <tr height="36px;">
                <td class="askl">充值总金额：</td>
                <td align="left">￥ <input type="text" name="recharge" id="recharge" size="9px"/></td>
            </tr>
            <tr>
                <td class="askl">充值原因：</td>
                <td align="left"><textarea name="rechargeRemark" id="rechargeRemark" style="width:300px;height: 60px;"></textarea></td>
            </tr>
        </table>
        <div class="neirboxok" style="width: 25%;margin:auto;margin-top: 26px;">
            <a class="anvbotton" href="javascript:void(0);" onclick="javascript:recharge(<?php echo $this->detail->id; ?>,$(this));"><span>确认充值</span></a>
        </div>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>



<script type="text/javascript">

    $(".dian").mouseenter(function() {
        $(this).next("div").attr("style", "display:block;");
    });
    $(".bzloading").mouseleave(function() {
        $(".bzloading .bzxiangbox").attr("style", "display:none;");
    });
    $('#interiorChange').click(function() {
        $('#interiorBox').show();
    });
    $('#interiorAll').mouseleave(function() {
        $('#interiorBox').hide();
    });

    function accepted(id) {
        $.post(
                '/admini/returngoods/accepted',
                {'id': id},
        function(data) {
            if (data === 1) {
                alert("受理成功！");
                location.reload();
            } else {
                alert("受理失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function deal(id) {
        $.post(
                '/admini/returngoods/deal',
                {'id': id},
        function(data) {
            if (data === 1) {
                alert("处理成功！");
                location.reload();
            } else {
                alert("处理失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function send(id, obj) {
        var span = obj.children('span');
        if ('已发包' != span.text()) {
            return false;
        }
        span.text('已发包...');
        var logisticsName = $('#logisticsName').val();
        var logistics = $('#logistics').val();
        var freight = $('#freight').val();
        var returnType = $("#returnType").val();
        if (logistics.length <= 1 || logisticsName.length <= 1 || freight < 0) {
            alert("快递公司、快递单号、运费都不能为空！");
            return false;
        } else {
            if (isNaN(freight)) {
                alert("运费必须是数字！");
                return false;
            }
            $.post(
                    '/admini/returngoods/send',
                    {'id': id, 'logistics': logistics, 'logisticsName': logisticsName, 'freight': freight, 'returnType': returnType},
            function(data) {
                span.text('已发包');
                if (data === 1) {
                    alert("操作成功！(已发包)");
                    location.reload();
                } else if (data === 2) {
                    alert("用户余额不够扣运费，请及时联系客户充值！");
                } else {
                    alert("操作失败！");
                    location.reload();
                }
            }
            , 'json');
        }
    }

    function notice(id) {
        $.post(
                '/admini/returngoods/notice',
                {'id': id},
        function(data) {
            if (data === 1) {
                alert("操作成功！(已通知)");
                location.reload();
            } else {
                alert("操作失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function waitingreceipt(id) {
        $.post(
                '/admini/returngoods/waitingreceipt',
                {'id': id},
        function(data) {
            if (data === 1) {
                alert("操作成功！(对方已收件)");
                location.reload();
            } else {
                alert("操作失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function refund(id) {
        $.post(
                '/admini/returngoods/refund',
                {'id': id},
        function(data) {
            if (data === 1) {
                alert("操作成功！(卖家已退款)");
                location.reload();
            } else {
                alert("操作失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function succeed(id) {
        $.post(
                '/admini/returngoods/succeed',
                {'id': id},
        function(data) {
            if (data.type === 1) {
                alert("操作成功！(退换货完成)");
                location.reload();
            } else {
                alert("操作失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function resend(id,obj) {
        var span = obj.children('span');
        if('对方已发件' != span.text()){
            return false;
        }
        obj.text('对方已发件...');
        var reLogisticsName = $('#reLogisticsName').val();
        var reLogistics = $('#reLogistics').val();
        var reFreight = $('#reFreight').val();
        if (reLogisticsName.length <= 1 || reLogistics.length <= 1 || reFreight < 0) {
            alert("快递公司、快递单号、运费都不能为空！");
            return false;
        }
        if (isNaN(reFreight)) {
            alert("运费必须是数字！");
            return false;
        }
        $.post(
                '/admini/returngoods/resend',
                {'id': id, 'reLogisticsName': reLogisticsName, 'reLogistics': reLogistics, 'reFreight': reFreight},
        function(data) {
            span.text('对方已发件');
            if (data === 1) {
                alert("操作成功！(对方已发件)");
                location.reload();
            } else if (data === 2) {
                alert("用户余额已不够扣运费，请及时联系客户充值！");
            } else {
                alert("操作失败！");
                location.reload();
            }
        }
        );
    }

    function receipt(id) {
        $.post(
                '/admini/returngoods/receipt',
                {'id': id},
        function(data) {
            if (data === 1) {
                alert("操作成功！(退换货完成)");
                location.reload();
            } else {
                alert("操作失败！");
                location.reload();
            }
        }
        , 'json');
    }

    function editInterior(interior) {
        var id = $('#editInterior' + interior).attr("name");
        var name = $('#editInterior' + interior).html();
        if (confirm("您确定要修改成" + name)) {
            $.post(
                    '/admini/returngoods/changeinterior',
                    {'id': id, 'interior': interior},
            function(data) {
                if (data === 1) {
                    alert("修改后台状态成功！");
                    location.reload();
                } else {
                    alert("修改状态失败！");
                }
            }
            , 'json');
        }
    }

    function deletebyid(id) {
        if (confirm("确认要删除？？")) {
            $.post(
                    '/admini/returngoods/deletebyid',
                    {'id': id},
            function(data) {
                if (data === 1) {
                    alert("操作成功！(取消删除)");
                    location.reload();
                } else if (data === 2) {
                    alert("已经发出的包裹无法取消删除！");
                    location.reload();
                } else {
                    alert("操作失败！");
                    location.reload();
                }
            }
            , 'json');
        }
    }

    function remark() {
        $('#box_remark').show();
        $('.unusualbox').hide();
        $('.houtai_overlay').show();
        $('.neirbox').show();
        $('.rechargebox').hide();
        $('#edithead').html("修改备注");
    }

    $('#exitissue').click(function() {
        $('#box_remark').hide();
        $('.houtai_overlay').hide();
    });

    function editRemark(id) {
        var remark = $('#remark').val();
        $.post(
                '/admini/returngoods/editremark',
                {'id': id, 'remark': remark},
        function(data) {
            if (data === 1) {
                alert("修改备注成功！");
                location.reload();
            } else {
                alert("修改备注成功！");
            }
        }
        , 'json');
    }

    function unusual() {
        $('#box_remark').show();
        $('.neirbox').hide();
        $('.rechargebox').hide();
        $('#edithead').html("记录异常信息");
        $('.unusualbox').show();
        $('.houtai_overlay').show();
    }

    function abnormal(id) {
        if (confirm("您确认该退换货出现异常", "提示信息")) {
            var exception = $('#exception').val();
            if (exception == "") {
                alert("异常内容不能为空！");
                return false;
            }
            $.post(
                    '/admini/returngoods/abnormal',
                    {'id': id, 'exception': exception},
            function(data) {
                if (data === 1) {
                    alert("记录异常信息成功！");
                    location.reload();
                } else {
                    alert("操作失败！！");
                }
            }
            , 'json');
        }
    }

    function process(id)
    {
        if (confirm("您确认该异常已经处理", "提示信息")) {
            var exception = $('#exception').val();
            if (exception == "") {
                alert("异常内容不能为空！");
                return false;
            }
            $.post(
                    '/admini/returngoods/process',
                    {'id': id, 'exception': exception},
            function(data) {
                if (data === 1) {
                    alert("标记异常已处理！");
                    location.reload();
                } else {
                    alert("操作失败！");
                }
            }
            , 'json');
        }
    }

    function loss(id) {
        if (confirm("您确认该退换货包裹丢失", "提示信息")) {
            var exception = $('#exception').val();
            if (exception == "") {
                alert("异常内容不能为空！");
                return false;
            }
            $.post(
                    '/admini/returngoods/loss',
                    {'id': id, 'exception': exception},
            function(data) {
                if (data === 1) {
                    alert("标记包裹丢失！");
                    location.reload();
                } else {
                    alert("操作失败！");
                }
            }
            , 'json');
        }
    }

    function rechargebox() {
        $('#box_remark').show();
        $('.neirbox').hide();
        $('#edithead').html("会员充值");
        $('.unusualbox').hide();
        $('.rechargebox').show();
        $('.houtai_overlay').show();
    }

    function recharge(id,obj) {
        var span = obj.children('span');
        if('确认充值' != span.text()){
            return false;
        }
        span.text('确认充值...');
        var recharge = $('#recharge').val();
        var rechargeRemark = $("#rechargeRemark").val();
        var orderRecharge = $('.orderReturngoodsMoney'),
            oRecharges = new Array(),
            isInputOrecharge = true;
        for(var i =0;i<orderRecharge.length;i++){
            var oRecharge = {};
            if(!orderRecharge.eq(i).val() || 0 >= orderRecharge.eq(i).val()){
                isInputOrecharge = false;
                break;
            }
            oRecharge.order_sn = orderRecharge.eq(i).attr('name');
            oRecharge.value = orderRecharge.eq(i).val();
            oRecharges.push(oRecharge);
        }
        if (recharge > 0 && recharge !== "" && isInputOrecharge) {
            $.post(
                    '/admini/returngoods/recharge',
                    {'id': id, 'recharge': recharge,'orecharge' :$.toJSON(oRecharges),"rechargeRemark": rechargeRemark},
            function(data) {
                span.text('确认充值');
                if (data === 1) {
                    alert("成功充值！");
                    location.reload();
                } else {
                    alert("操作失败！");
                }
            }
            , 'json');
        } else {
            span.text('确认充值');
            alert("输入的值不合法！");
        }
    }

    $(function() {
        $('.courierCompany').bind('click', function(et) {
            et.stopPropagation();
            et.stopImmediatePropagation();
            $(this).parent('.biaoxiala').children('.kdtc:first').show();
        })

        $('.kdzm a').each(function(index, item) {
            $(item).click(function() {
                $('.kdzm li.kon').removeClass('kon');
                $(this).parent().addClass('kon');
                $('#courierTb ul').hide();
                $('#courierTb ul').eq(index).show();
                return false;
            });
        });

        $(document).bind('click', function(et) {
            et.stopPropagation();
            et.stopImmediatePropagation();
            $('.kdtc:first').hide();
        })
        $('.kditem').bind('click', function() {
            var logisticsName = $(this).text();
            var company = $(this).closest('.biaoxiala').children('.courierCompany');
            company.children('span').text(logisticsName);
            company.prev('.textbox').children('input').val(logisticsName);
            company.children('.kdtc:first').hide();
        })
        
        $('.orderReturngoodsMoney').bind('blur',function(){
            var inputs = $('.orderReturngoodsMoney'),
                totals = 0,
                val = 0;
            for(var i =0;i<inputs.length;i++){
                val = 0;
                if(inputs.eq(i).val()){
                    val = inputs.eq(i).val();
                }
                
                totals += parseFloat(val);
            }
            $('#recharge').val(totals);
            
        })
    })

</script>
